using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerManager : Singleton<PlayerManager>,ISaveManager
{
    private Player player;
    public Player Player
    {
        get
        {
            if(player == null)
            {
                player = GameObject.Find("Player").GetComponent<Player>();
            }                         
            return player;
        }
        set
        {
            player = value;
        }
    }
    private int currency;

    public int Currency
    {
        get
        {
            return currency;
        }
        set
        {
            currency = value;
            if(OnMoneyChanged != null)
                OnMoneyChanged();
        }
    }

    public Action OnMoneyChanged;


    public void LoadData(GameData _gameData)
    {
        currency = _gameData.currency;
    }

    public void SaveData(ref GameData _gameData)
    {
        _gameData.currency = currency;
    }
}
